package com.yangrd.airship.upms.infrastructure;

import com.alibaba.fastjson.JSON;

import javax.persistence.AttributeConverter;
import java.util.List;

/**
 * description: List2StrConvert
 *
 * @author: yangrd
 * @date: 2021/6/24
 * @version: 1.0
 */
public class List2StrAttributeConverter implements AttributeConverter<List<String>, String> {
    @Override
    public String convertToDatabaseColumn(List<String> strings) {
        return JSON.toJSONString(strings);
    }

    @Override
    public List<String> convertToEntityAttribute(String s) {
        return JSON.parseArray(s, String.class);
    }
}
